package practice1_100;

import java.util.ArrayList;
import java.util.List;

public class Quan {
    public List<List<Integer>> subsets(int[] nums) {
        List<List> list=new ArrayList<>();
       return dp(nums, nums.length-1,list,1 );
    }
    public List dp(int[] nums,int index,List<List> list,int state){
        //dp终止条件
        if(index<0) return null;
        if(index==0&&state==0){
            List listInt= new ArrayList<Integer>();
            //list.add(listInt);
            return listInt;
        }
        if(index==0&&state==1) {
            List listInt= new ArrayList<Integer>();
            listInt.add(nums[index]);
            //list.add(listInt);
            return listInt;
        }


        if(state==1){
           List list1=  dp(nums,index-1,list,state);
           list.add(list1);
           state=0;
           List list2= dp(nums,index-1,list,state);
           list.add(list2);
        }else {
            List list3=dp(nums,index-1,list,state);
            list.add(list3);
            state=1;
            List list4=dp(nums,index-1,list,state);
            list.add(list4);
        }
        return list;


    }

    public static void main(String[] args) {

        List list= new Quan().subsets(new int[]{1,2,3});
        System.out.println(list);

    }
}
